package hist_data;

import java.util.Date;

import iblink.core.HistoricalData;

public class MinuteBar {

	protected Date date;

	protected double open;

	protected double high;

	protected double low;

	protected double close;

	protected int volume;

	protected int count;

	protected double wap;

	protected Double sodChange;

	protected Double oneBarChange;

	protected Double fiveBarChange;

	protected Double tenBarChange;

	private boolean computedFieldsSet = false;

	public boolean computedFieldsSet() {
		return computedFieldsSet;
	}

	public Double getSodChange() {
		return sodChange;
	}

	public Double getOneBarChange() {
		return oneBarChange;
	}

	public Double getFiveBarChange() {
		return fiveBarChange;
	}

	public Double getTenBarChange() {
		return tenBarChange;
	}

	public void setComputedFields(double sodChange, Double oneBarChange,
			Double fiveBarChange, Double tenBarChange) {
		this.sodChange = sodChange;
		this.oneBarChange = oneBarChange;
		this.fiveBarChange = fiveBarChange;
		this.tenBarChange = tenBarChange;
		computedFieldsSet = true;
	}

	public MinuteBar(Date date, double open, double high, double low,
			double close, int volume, int count, double wap) {
		this.date = date;
		this.open = open;
		this.high = high;
		this.low = low;
		this.close = close;
		this.volume = volume;
		this.count = count;
		this.wap = wap;
	}

	public MinuteBar(Date date, double open, double high, double low,
			double close, int volume, int count, double wap,
			double percentChangeFromStartOfDay) {
		this.date = date;
		this.open = open;
		this.high = high;
		this.low = low;
		this.close = close;
		this.volume = volume;
		this.count = count;
		this.wap = wap;
		this.sodChange = percentChangeFromStartOfDay;
	}

	public MinuteBar(HistoricalData histData) {
		date = histData.getDate();
		open = histData.getOpen();
		high = histData.getHigh();
		low = histData.getLow();
		close = histData.getClose();
		volume = histData.getVolume();
		count = histData.getCount();
		wap = histData.getWAP();
	}

	public String toString() {
		return getClass().getSimpleName() + "[ date[" + date + "] open[" + open
				+ "] high[" + high + "] low[" + low + "] close[" + close
				+ "] volume[" + volume + "] count[" + count + "] wap[" + wap
				+ "] percentChangeFromStartOfDay[" + sodChange + "]]";
	}

	public Date getDate() {
		return date;
	}

	public double getOpen() {
		return open;
	}

	public double getHigh() {
		return high;
	}

	public double getLow() {
		return low;
	}

	public double getClose() {
		return close;
	}

	public int getVolume() {
		return volume;
	}

	public int getCount() {
		return count;
	}

	public double getWAP() {
		return wap;
	}

	public double getPercentChangeFromSOD() {
		return sodChange;
	}
}
